package micotime.com.amap_plugin;

import android.content.Context;

import androidx.annotation.NonNull;

import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationListener;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;
import micotime.com.amap_plugin.map.AMapLocation;
import micotime.com.amap_plugin.map.AMapView;
import micotime.com.amap_plugin.map.AMapViewFactory;

/**
 * 高德地图插件入口
 */
public class AmapPlugin implements FlutterPlugin {

    private static final String TAG = "AmapLocationPlugin";

    @Override
    public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
        AMapLocation aMapLocation = new AMapLocation(flutterPluginBinding.getApplicationContext());
        aMapLocation.register(flutterPluginBinding.getBinaryMessenger());

        flutterPluginBinding.getPlatformViewRegistry().registerViewFactory("plugins.yanwc/amap_view",
                new AMapViewFactory(flutterPluginBinding.getBinaryMessenger()));
    }

    @Override
    public void onDetachedFromEngine(FlutterPluginBinding flutterPluginBinding) {
    }

    public static void registerWith(Registrar registrar) {
        AMapLocation aMapLocation = new AMapLocation(registrar.context());
        aMapLocation.register(registrar.messenger());
        registrar.platformViewRegistry().registerViewFactory("plugins.yanwc/amap_view",
                new AMapViewFactory(registrar.messenger()));
    }

}
